﻿using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Threading;

namespace ViewModels.DinosaursParkMes.DataTime
{
    public class MainWindowViewModel:BindableBase
    {
        public MainWindowViewModel()
        {
            var priority = new DispatcherPriority();
            priority = DispatcherPriority.Send;//设置优先级为最高（按需）
            DispatcherTimer timer = new DispatcherTimer(priority);
            timer.Interval = new TimeSpan(0, 0, 0, 1);
            timer.Tick += timer_Tick;
            timer.IsEnabled = true;
        }
        /**************************************************************/
        /*当前日期*/
        private string _DateNow;
        public string DateNow
        {
            get { return _DateNow; }
            set { _DateNow = value; RaisePropertyChanged(); }
        }
        /*当前时间*/
        private string _TimeNow;
        public string TimeNow
        {
            get { return _TimeNow; }
            set { _TimeNow = value; RaisePropertyChanged(); }
        }
        /*事件处理器*/
        private void timer_Tick(object sender, EventArgs e)
        {
            DateNow = DateTime.Now.ToString("yyyy-MM-dd ");
            TimeNow = DateTime.Now.ToString("HH:mm:ss");
        }

       
    }
}
